<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
//系统链接获取接口
$return=array();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'system';
$tabs=array(
	array('op'=>'system','query'=>'onlyplugin='.$_RQ['onlyplugin'],'title'=>'系统页面链接'),
	array('op'=>'article_list','query'=>'onlyplugin='.$_RQ['onlyplugin'],'title'=>'文章列表'),
	array('op'=>'article','query'=>'onlyplugin='.$_RQ['onlyplugin'],'title'=>'文章详情'),
	array('op'=>'diy_url','query'=>'onlyplugin='.$_RQ['onlyplugin'],'title'=>'自定义链接'),
);
if($_RQ['op']=='diy_url'){
	$return['item']=array('url'=>'');
	$return['htmls']=array(
		'type'=>'edit',
		'post'=>'modal_result',
		'result_field'=>'url',
		'edit'=>array(
			array('type'=>'string','name'=>'url','title'=>'链接地址'),
		),
	);
	exi($return);
}
if($_RQ['op']=='system'){
	$return['list']=get_managehome_pages();
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'pagelist'=>false,'list'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'url','title'=>'链接地址','type'=>'string'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'url','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='article'){
	$pindex=max(1,intval($_RQ['page']));
	$psize=10;
	$params=array();
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$total=0;
	$fields=array('id','title','createtime');
	$list=pdo_getslice('core_article',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['createtime']=date('y/m/d H:i:s',$item['createtime']);

			$item['url']='core/home.news_detail//id='.$item['id'];

		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'list'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'url','title'=>'链接地址','type'=>'string'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'url','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='article_list'){
	$pindex=max(1,intval($_RQ['page']));
	$psize=10;
	$params=array();
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$total=0;
	$fields=array('id','title','createtime');
	$list=pdo_getslice('core_article_group',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['createtime']=date('y/m/d H:i:s',$item['createtime']);
			$item['url']='core/home.news//id='.$item['id'];
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'list'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'url','title'=>'链接地址','type'=>'string'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'url','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	$return['htmls']=$htmls;
	exi($return);
}
?>

